// components/nav-bar/nav-bar.js

function calcTopBar() {
  let menuReact = wx.getMenuButtonBoundingClientRect();
  let {statusBarHeight, screenWidth} = wx.getSystemInfoSync();
  return {
    screenWidth,
    sh: statusBarHeight, // 状态栏占位高度
    nbh: menuReact.height + (menuReact.top - statusBarHeight) * 2, // 导航高度
    pr: screenWidth - menuReact.left, // 导航右内边距
    pl: screenWidth - menuReact.right, //导航左内边距
  }
}

Component({
  externalClasses: ['custom-class', 'placeholder-class'],
  options: {
    addGlobalClass: true,
    multipleSlots: true
  },
  /**
   * 组件的属性列表
   */
  properties: {
    title: {
      type: String,
      value: ''
    },
    showBack: {
      type: Boolean,
      value: false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    barSize: {
      ...calcTopBar()
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {

  }
})
